#include "dataDefination.h"

void recordListSet::destroyListSet()
{
    for (int i = 0; i < mListSet.size(); ++i) {
        delete mListSet.at(i);
    }
}

recordListSet::~recordListSet()
{
    destroyListSet();
}


bool recordListSet::insertRecordInfo(const QString & ip, const recordInfo & info)
{
    QList<recordInfo> * list;
    if (!mHash.contains(ip)) {
        list = new QList<recordInfo>;
        if (!list) {
            return false;
        }
        mListSet.append(list);
        mHash.insert(ip, list);
    } else {
        list = mHash.value(ip);
        if (!list) {
            return false;
        }
    }
    list->append(info);
    return true;
}

bool recordListSet::clearRecordInfo(const QString & ip)
{
    QList<recordInfo> * list;
    if (!mHash.contains(ip)) {
        return false;
    } else {
        list = mHash.value(ip);
        list->clear();
        return true;
    }
}
